package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.AddressMapper;
import com.atguigu.spzx.manager.service.AddressService;
import com.atguigu.spzx.model.entity.system.SysUser;
import com.atguigu.spzx.model.vo.address.addressVo;
import com.atguigu.spzx.utils.AuthContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.atguigu.spzx.model.dto.address.useraddressDto;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    private AddressMapper addressMapper;

    @Override
    public List<addressVo> GetAddressById(Long id) {
        List<addressVo> addressVo = addressMapper.getAddressByid(id);
        return addressVo;
    }

    @Override
    public void deleteAddressById(Long id) {
        addressMapper.deleteAddressByid(id);
    }

    @Override
    public void alterAddressById(useraddressDto useraddressDto) {
        addressMapper.alterAddressByid(useraddressDto);
    }

    @Override
    public void saveAddress(useraddressDto useraddressDto) {
        SysUser sysUser = AuthContextUtil.get();
        useraddressDto.setUserId(sysUser.getId());
        addressMapper.saveAddress(useraddressDto);
    }

}
